$(function ($) {
	//数据开放统计 Box05	
	//数据开放统计 按钮切换	

	var myChart = echarts.init(document.getElementById('DataBox05_Data_Field'));
	

	option = {
			tooltip: {
				trigger: "axis",
				axisPointer: {
					type: "shadow",
					textStyle: {
						color: "#dbe9fc"
					}

				},
			},
			grid: {
				top: 50,
				bottom:40,
				right:40,
				left:40,
				calculable: true,
				textStyle: {
					fontFamily: 'Microsoft Yahei',
				}
			},
			legend: {
				right: '50',
				top: '0',
				textStyle: {
					color: '#dbe9fc',
					fontSize: 14,
					fontFamily: 'Microsoft Yahei',
				},
				data: ['API','文件', '应用','总数']
			},



			xAxis: [{
				type: 'category',
				axisLine: {
					show: true,
					lineStyle: {
						color: '#e5e5e5'
					}
				},
				axisLabel: {
					show: true,
					margin: 10,
					interval:0,  
					rotate:0,
					textStyle: {
						color: '#dbe9fc',
						fontSize: 12,
						fontFamily: 'Microsoft Yahei',

					},
					formatter: function(val) {
						var strs = val.split(''); //字符串数组
						var str = ''
						for(var i = 0, s; s = strs[i++];) { //遍历字符串数组
						str += s;
						if(!(i % 2)) str += '\n'; //按需要求余
						}
						return str
						},
					
				},
				axisTick: {
					show: false
				},
				splitLine: {
					show: false
				},
				data: (function(){
		            var arr=[];
		            $.ajax({
		            	method: 'GET',
		                 async : false, //同步执行
		                 url : DataOpen.apiHostName + '/dataopen/statistics/dataset/countByTypeAndTopic',
		                 data : {topNum:20},
		                 dataType : "json", //返回数据形式为json
		                 success : function(result) {
		                	 if (result.code == 'success') {
			                	 $.each(result.data, function(index, item) { 
			                		 arr.push(item.name);
			                	 })
		                	 }
		                                        
		                },
		                    error : function(errorMsg) {
		                        alert("不好意思，图表请求数据失败啦!");
		                         myChart.hideLoading();
		                       }
		               })
		                 return arr;
		              })() , 
			}],
			


			
			
			
			yAxis: [{
				type: 'value',
				axisLabel: {
					show: true,
					margin: 14,
					textStyle: {
						color: '#dbe9fc',
						fontSize: 12,
						fontFamily: 'Microsoft Yahei',

					}
				},
				axisLine: {
					show: false
				},
				axisTick: {
					show: false
				},
				splitLine: {
					show: true,
					lineStyle: {
						color: 'rgba(255,255,255, 0.2)',
						type: 'dashed',
					}
				},
			}],
			series: [{
					name: "API",
					type: "bar",
					stack: "总量",
					barMaxWidth: 10,
					barGap: 0,
					itemStyle: {
						normal: {
							color: "#27d4ff",
							shadowBlur:0,
							shadowOffsetY: 0,
							shadowColor: 'rgba(0, 218, 226, 0.42)',
							barBorderRadius: [0, 0, 0, 0],
							label: {
								show: false,
							}
						}
					},
					data : (function(){
			            var arr=[];
			            $.ajax({
			            	 method: 'GET',
			                 async : false, //同步执行
			                 url : DataOpen.apiHostName + '/dataopen/statistics/dataset/countByTypeAndTopic',
			                 data : {topNum:20},
			                 dataType : "json", //返回数据形式为json
			                 success : function(result) {
			                	 if (result.code == 'success') {
				                	 $.each(result.data, function(index, item) { 
				                		 arr.push(item.count_api);
				                	 })
			                	 }
			                                        
			                },
			                    error : function(errorMsg) {
			                        alert("不好意思,图表请求数据失败啦!");
			                         myChart.hideLoading();
			                       }
			               })
			                 return arr;
			              })() ,
				}, {
					name: "文件",
					type: "bar",
					stack: "总量",
					barMaxWidth: 10,
					barGap: 0.2,
					itemStyle: {
						normal: {
							color: "#4896ff",
							shadowBlur: 0,
							shadowOffsetY: 0,
							shadowColor: 'rgba(1, 129, 211, 0.42)',
							barBorderRadius: [0, 0, 0, 0],
							label: {
								show: false,
							}
						}
					},
					data : (function(){
			            var arr=[];
			            $.ajax({
			            	 method: 'GET',
			                 async : false, //同步执行
			                 url : DataOpen.apiHostName + '/dataopen/statistics/dataset/countByTypeAndTopic',
			                 data : {topNum:20},
			                 dataType : "json", //返回数据形式为json
			                 success : function(result) {
			                	 if (result.code == 'success') {
				                	 $.each(result.data, function(index, item) { 
				                		 arr.push(item.count_file);
				                	 })
			                	 }
			                                        
			                },
			                    error : function(errorMsg) {
			                        alert("不好意思,图表请求数据失败啦!");
			                         myChart.hideLoading();
			                       }
			               })
			                 return arr;
			              })() ,
				}, {
					name: "应用",
					type: "bar",
					stack: "总量",
					barMaxWidth: 10,
					barGap: 0.2,
					itemStyle: {
						normal: {
							color: "#ffb400",
							shadowBlur: 0,
							shadowOffsetY: 0,
							shadowColor: 'rgba(1, 129, 211, 0.42)',
							barBorderRadius: [0, 0, 0, 0],
							label: {
								show: false,
							}
						}
					},
					data : (function(){
			            var arr=[];
			            $.ajax({
			            	 method: 'GET',
			                 async : false, //同步执行
			                 url : DataOpen.apiHostName + '/dataopen/statistics/dataset/countByTypeAndTopic',
			                 data : {topNum:20},
			                 dataType : "json", //返回数据形式为json
			                 success : function(result) {
			                	 if (result.code == 'success') {
				                	 $.each(result.data, function(index, item) { 
				                		 arr.push(item.count_link);
				                	 })
			                	 }
			                                        
			                },
			                    error : function(errorMsg) {
			                        alert("不好意思,图表请求数据失败啦!");
			                         myChart.hideLoading();
			                       }
			               })
			                 return arr;
			              })() ,
				},{
					name: "总量",
					type: "line",
					symbolSize: 6,
					symbol: 'circle',
					lineStyle: {
						normal: {
							width: 2,
							type: 'solid',
							color: "rgba(219,233,252,0.2)",
						}
					},
					itemStyle: {
						normal: {
							color: "rgba(219,233,252,0.8)",
							label: {
								show: false,
							}
						}
					},
					data : (function(){
			            var arr=[];
			            $.ajax({
			            	method: 'GET',
			                 async : false, //同步执行
			                 url : DataOpen.apiHostName + '/dataopen/statistics/dataset/countByTypeAndTopic',
			                 data : {topNum:20},
			                 dataType : "json", //返回数据形式为json
			                 success : function(result) {
			                	 if (result.code == 'success') {
				                	 $.each(result.data, function(index, item) { 
				                		 arr.push(item.count_total);
				                	 })
			                	 }
			                                        
			                },
			                    error : function(errorMsg) {
			                        alert("不好意思，图表请求数据失败啦!");
			                         myChart.hideLoading();
			                       }
			               })
			                 return arr;
			              })() , 
				},

			]
		}
		// 使用刚指定的配置项和数据显示图表。
	myChart.setOption(option);

	$("#DataBox05_Data_Department,#DataBox05_Title02").hide();
	$("#Button_Field").click(function () {
		$("#Inf_Department").fadeOut(0);
		$("#DataBox05_Data_Department").fadeOut(300);
		$("#Inf_Field").fadeIn(300);
		$("#DataBox05_Data_Field").fadeIn(300);
		$(this).addClass("Button_Blue").siblings().removeClass("Button_Blue");
	})
	$("#Button_Department").click(function () {
		$("#Inf_Field").fadeOut(0);
		$("#DataBox05_Data_Field").fadeOut(300);
		$("#Inf_Department").fadeIn(300);
		$("#DataBox05_Data_Department").fadeIn(300);
		$(this).addClass("Button_Blue").siblings().removeClass("Button_Blue");
	})



	var myChart = echarts.init(document.getElementById('DataBox05_Data_Department'));

	option = {
			tooltip: {
				trigger: "axis",
				axisPointer: {
					type: "shadow",
					textStyle: {
						color: "#dbe9fc"
					}

				},
			},
			grid: {
				top: 50,
				bottom:40,
				right:40,
				left:40,
				calculable: true,
				textStyle: {
					fontFamily: 'Microsoft Yahei',
				}
			},
			legend: {
				right: '50',
				top: '0',
				textStyle: {
					color: '#dbe9fc',
					fontSize: 14,
					fontFamily: 'Microsoft Yahei',
				},
				data: [ 'API','文件','应用', '总数']
			},

			xAxis: [{
				type: 'category',
				axisLine: {
					show: true,
					lineStyle: {
						color: '#e5e5e5'
					}
				},
				axisLabel: {
					show: true,
					margin: 10,
					textStyle: {
						color: '#dbe9fc',
						fontSize: 12,
						fontFamily: 'Microsoft Yahei',

					},
				formatter: function(val) {
					var strs = val.split(''); //字符串数组
					var str = ''
					for(var i = 0, s; s = strs[i++];) { //遍历字符串数组
					str += s;
					if(!(i % 5)) str += '\n'; //按需要求余
					}
					return str
					},
				},
				
				axisTick: {
					show: false
				},
				splitLine: {
					show: false
				},
				data: (function(){
		            var arr=[];
		            $.ajax({
		            	method: 'GET',
		                 async : false, //同步执行
		                 url : DataOpen.apiHostName + '/dataopen/statistics/dataset/countByTypeAndOrg',
		                 data : {topNum:10},
		                 dataType : "json", //返回数据形式为json
		                 success : function(result) {
		                	 if (result.code == 'success') {
			                	 $.each(result.data, function(index, item) { 
			                		 arr.push(item.name);
			                	 })
		                	 }
		                                        
		                },
		                    error : function(errorMsg) {
		                        alert("不好意思，图表请求数据失败啦!");
		                         myChart.hideLoading();
		                       }
		               })
		                 return arr;
		              })() , 
			}],
			yAxis: [{
				type: 'value',
				axisLabel: {
					show: true,
					margin: 20,
					textStyle: {
						color: '#dbe9fc',
						fontSize: 12,
						fontFamily: 'Microsoft Yahei',

					}
				},
				axisLine: {
					show: false
				},
				axisTick: {
					show: false
				},
				splitLine: {
					show: true,
					lineStyle: {
						color: 'rgba(255,255,255, 0.2)',
						type: 'dashed',
					}
				},
			}],
			series: [{
					name: "API",
					type: "bar",
					barMaxWidth:10,
					barGap: 0,
					itemStyle: {
						normal: {
							color: "#27d4ff",
							shadowBlur:0,
							shadowOffsetY: 0,
							shadowColor: 'rgba(0, 218, 226, 0.42)',
							barBorderRadius: [0, 0, 0, 0],
							label: {
								show: false,
							}
						}
					},
					data: (function(){
			            var arr=[];
			            $.ajax({
			            	method: 'GET',
			                 async : false, //同步执行
			                 url : DataOpen.apiHostName + '/dataopen/statistics/dataset/countByTypeAndOrg',
			                 data : {topNum:10},
			                 dataType : "json", //返回数据形式为json
			                 success : function(result) {
			                	 if (result.code == 'success') {
				                	 $.each(result.data, function(index, item) { 
				                		 arr.push(item.count_api);
				                	 })
			                	 }
			                                        
			                },
			                    error : function(errorMsg) {
			                        alert("不好意思，图表请求数据失败啦!");
			                         myChart.hideLoading();
			                       }
			               })
			                 return arr;
			              })() ,
				}, {
					name: "文件",
					type: "bar",
					barMaxWidth:10,
					barGap: 0.2,
					itemStyle: {
						normal: {
							color: "#4896ff",
							shadowBlur:0,
							shadowOffsetY: 0,
							shadowColor: 'rgba(1, 129, 211, 0.42)',
							barBorderRadius: [0, 0, 0, 0],
							label: {
								show: false,
							}
						}
					},
					data: (function(){
			            var arr=[];
			            $.ajax({
			            	method: 'GET',
			                 async : false, //同步执行
			                 url : DataOpen.apiHostName + '/dataopen/statistics/dataset/countByTypeAndOrg',
			                 data : {topNum:10},
			                 dataType : "json", //返回数据形式为json
			                 success : function(result) {
			                	 if (result.code == 'success') {
				                	 $.each(result.data, function(index, item) { 
				                		 arr.push(item.count_file);
				                	 })
			                	 }
			                                        
			                },
			                    error : function(errorMsg) {
			                        alert("不好意思，图表请求数据失败啦!");
			                         myChart.hideLoading();
			                       }
			               })
			                 return arr;
			              })() ,
				}, {
					name: "应用",
					type: "bar",
					barMaxWidth: 10,
					barGap: 0.2,
					itemStyle: {
						normal: {
							color: "#ffb400",
							shadowBlur:0,
							shadowOffsetY: 0,
							shadowColor: 'rgba(1, 129, 211, 0.42)',
							barBorderRadius: [0, 0, 0, 0],
							label: {
								show: false,
							}
						}
					},
					data: (function(){
			            var arr=[];
			            $.ajax({
			            	method: 'GET',
			                 async : false, //同步执行
			                 url : DataOpen.apiHostName + '/dataopen/statistics/dataset/countByTypeAndOrg',
			                 data : {topNum:10},
			                 dataType : "json", //返回数据形式为json
			                 success : function(result) {
			                	 if (result.code == 'success') {
				                	 $.each(result.data, function(index, item) { 
				                		 arr.push(item.count_link);
				                	 })
			                	 }
			                                        
			                },
			                    error : function(errorMsg) {
			                        alert("不好意思，图表请求数据失败啦!");
			                         myChart.hideLoading();
			                       }
			               })
			                 return arr;
			              })() ,
				}, {
					name: "总量",
					type: "line",
					symbolSize: 6,
					symbol: 'circle',
					lineStyle: {
						normal: {
							width: 2,
							type: 'solid',
							color: "rgba(219,233,252,0.2)",
						}
					},
					itemStyle: {
						normal: {
							color: "rgba(219,233,252,0.8)",
							label: {
								show: false,
							}
						}
					},
					data: (function(){
			            var arr=[];
			            $.ajax({

			            	method: 'GET',
			                 async : false, //同步执行
			                 url : DataOpen.apiHostName + '/dataopen/statistics/dataset/countByTypeAndOrg',
			                 data : {topNum:10},
			                 dataType : "json", //返回数据形式为json
			                 success : function(result) {
			                	 if (result.code == 'success') {
				                	 $.each(result.data, function(index, item) { 
				                		 arr.push(item.count_total);
				                	 })
			                	 }
			                                        
			                },
			                    error : function(errorMsg) {
			                        alert("不好意思，图表请求数据失败啦!");
			                         myChart.hideLoading();
			                       }
			               })
			                 return arr;
			              })() ,
				},

			]
		}
		// 使用刚指定的配置项和数据显示图表。
	myChart.setOption(option);
});